package com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.entity.req.SmsWnsEnrolNoticeReq;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.service.SmsWnsEnrolNoticeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 入学须知表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-25
 */
@RestController
@RequestMapping("/welcomeNewStudent/enrolNotice")
@SecretBody
public class SmsWnsEnrolNoticeController {


    @Resource
    private SmsWnsEnrolNoticeService smsWnsEnrolNoticeService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @ApiOperation("添加入学须知")
    @PostMapping("/add")
    public ResponseResult addEnrolNotice(HttpServletRequest request, @RequestBody SmsWnsEnrolNoticeReq addReq){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsWnsEnrolNoticeService.addEnrolNotice(userId,addReq);
    }

    @ApiOperation("删除入学须知")
    @PostMapping("/deleted")
    public ResponseResult deletedEnrolNotice(@RequestBody SmsWnsEnrolNoticeReq deletedReq){
        return smsWnsEnrolNoticeService.deletedEnrolNotice(deletedReq);
    }


    @ApiOperation("修改入学须知")
    @PostMapping("/update")
    public ResponseResult updateEnrolNotice(@RequestBody SmsWnsEnrolNoticeReq updateReq){
        return smsWnsEnrolNoticeService.updateEnrolNotice(updateReq);
    }

    @ApiOperation("获取入学须知详情")
    @GetMapping("/id")
    public ResponseResult getEnrolNoticeDetail(@RequestParam(value = "id")String id){
        return smsWnsEnrolNoticeService.getEnrolNoticeDetail(id);
    }

    @ApiOperation("获取入学须知列表")
    @GetMapping("/list")
    public ResponseResult getEnrolNoticeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "publishTime", required = false) String publishTime,
                                             @RequestParam(value = "theme", required = false) String theme,
                                             @RequestParam(value = "publisher", required = false) String publisher,
                                             @RequestParam(value = "isPost", required = false) Integer isPost){
        return smsWnsEnrolNoticeService.getEnrolNoticeList(publishTime,theme,publisher,isPost,pageNum,pageSize);
    }


}

